package ee.android.kinokavad.utils;

import java.util.Map;

import android.content.Context;
import android.util.Log;

import com.flurry.android.FlurryAgent;

import ee.android.kinokavad.App;
import ee.android.kinokavad.R;

public abstract class LogUtils {
	
	public static abstract class Logger {

		public static void v(String TAG, String msg) {
			if (App.LOCAL_LOG)
				Log.v(TAG, msg);
		}

		public static void d(String TAG, String msg) {
			if (App.LOCAL_LOG)
				Log.d(TAG, msg);
		}

		public static void i(String TAG, String msg) {
			if (App.LOCAL_LOG)
				Log.i(TAG, msg);
		}

		public static void w(String TAG, String msg) {
			if (App.LOCAL_LOG)
				Log.w(TAG, msg);
		}

		public static void e(String TAG, Throwable e) {
			if (App.LOCAL_LOG)
				Log.e(TAG, Log.getStackTraceString(e));
		}
		
		public static void e(String TAG, String msg) {
			if (App.LOCAL_LOG)
				Log.e(TAG, msg);
		}

		public static void e(String TAG, String msg, Throwable e) {
			if (App.LOCAL_LOG)
				Log.e(TAG, String.format("[%s] %s", msg, Log.getStackTraceString(e)));
		}
	}
	
	public interface LogEvent {
		
		public static final String EDIT_WORKOUT = "Workout Edited";
		
	}

	public static void onEvent(String eventId, Map<String, String> parameters) {
		if (App.FLURRY_LOG) {
			FlurryAgent.logEvent(eventId, parameters);
		}
	}

	public static void onEvent(String eventId) {
		if (App.FLURRY_LOG) {
			onEvent(eventId, null);
		}
			
	}

	public static void onError(String TAG, String message, Throwable throwable) {
		if (App.FLURRY_LOG) {
			FlurryAgent.onError(TAG, message, throwable);
		}
	}

	public static void onStartSession(Context context) {
		if (App.FLURRY_LOG) {
			FlurryAgent.onStartSession(context, context.getString(R.string.flurry_key));
			FlurryAgent.setUseHttps(true);
		}
	}

	public static void onEndSession(Context context) {
		if (App.FLURRY_LOG)
			FlurryAgent.onEndSession(context);
	}

}
